import babelpolyfill from 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
//import './assets/theme/theme-green/index.css'
import VueRouter from 'vue-router'
import store from './vuex/store'
import Vuex from 'vuex'
//import NProgress from 'nprogress'
//import 'nprogress/nprogress.css'
import routes from './routes'
//import Mock from './mock'
//  Mock.bootstrap();
import 'font-awesome/css/font-awesome.min.css'
//引入axios
import axios from 'axios'
//配置axios的全局基本路径，访问后端接口使用8080
axios.defaults.baseURL='http://localhost:8080/'
Vue.prototype.$http = axios
/*axios.defaults.baseURL='/api'*/

Vue.use(ElementUI)
Vue.use(VueRouter)
Vue.use(Vuex)

//NProgress.configure({ showSpinner: false });

const router = new VueRouter({
  routes
})

/*
//路由前置拦截器：每一次经过路由的请求之前都要去执行以下逻辑
router.beforeEach((to, from, next) => {
  //如果你请求的是login，我就从session中移除user信息
  if (to.path == '/login') {
    sessionStorage.removeItem('user');
  }
  //从session中获取user信息
  let user = JSON.parse(sessionStorage.getItem('user'));
  //如果user为空并且请求地址也不是login = 没有登录成功并且向访问其他资源
  if (!user && to.path != '/login') {
    //跳转到登录页面
    next({ path: '/login' })
  } else {
    //放行
    next()
  }
})
*/

//路由后置拦截器：每一次通过路由的请求之后都要去执行以下逻辑
//router.afterEach(transition => {
//NProgress.done();
//});

new Vue({
  //el: '#app',
  //template: '<App/>',
  router,
  store,
  //components: { App }
  render: h => h(App)
}).$mount('#app')

